<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="net.groupme.controller.oauth.OAuthProtocol"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- meta tags, link to css:  -->
	<%@ include file="../jsp-includes/mymetaheader.jsp" %>
	
	<!--  Ajax-Includes -->
    <script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRUserManager.js'></script>
    <script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/DWRSearchManager.js'></script>
    <script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>
    <script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'></script>
    <script src="<%= request.getContextPath()%>/scriptaculous/prototype.js" type="text/javascript"></script>
	<script src="<%= request.getContextPath()%>/scriptaculous/scriptaculous.js" type="text/javascript"></script>

	<title>
		GroupMe! - The Social Semantic Web  
		<c:choose>
			<c:when test="${userManager.loggedIn}">
				[Account Management]	 			
	 		</c:when>
			<c:otherwise>
				[Registration]
			</c:otherwise>
		</c:choose>
	</title>
	<script type="text/javascript" language="javascript"><!--
	//<![CDATA[//>


function init() {
  DWRUtil.useLoadingMessage();
}

	//<!]]>
	--></script>
</head>
<body onload="init();">
	<!-- title image, logo:  -->
	<div id="groupme_header">
		<%@ include file="../jsp-includes/groupme_header.jsp" %>
	</div>
	
	<!-- Menu: -->
	<div id="menu">
		<%@ include file="../jsp-includes/groupme_menu.jsp" %>
	</div>
	<!-- content and sidebar -->
	<!-- Content: -->
	<div id="mycontent">
		
			<div class="ro_bw">
				<div class="lo_bw">
					<div class="ru_bw">
						<div class="lu_bw">
							<div id="user_groups">
								<div class="content_header" id="grouplist_header" style="padding-top: 2px">
									<small style="color: #006699;">
									<span id="register_header">
										<c:choose>
											<c:when test="${userManager.loggedIn}">
												Manage Authorizations
	 										</c:when>
											<c:otherwise>
												Login
											</c:otherwise>
										</c:choose>
									</span> 
									</small>
								</div>
								<%
								String appDesc = (String)request.getAttribute("CONS_DESC");
								String token = (String)request.getAttribute("TOKEN");
								String callback = (String)request.getAttribute("CALLBACK");
								if(callback == null){
									callback = "";
								}%>
								<div class="generalContent" style="">
								<c:choose>
									<c:when test="${userManager.loggedIn}">
									<div id="personal-menu" style="font-size: 0.8em;">Menu: 
											 <a href="<%=VIEW_VOCABULARY.RESTful_USER_URI_PATTERN + userManager.getUser().getUserName() %>" title="Your profile page...">you</a>
											| <a href="./<%=VIEW_VOCABULARY.ACTION_HOME%>?<%=VIEW_VOCABULARY.PARAMETER_MYHOME_VIEW %>=<%=VIEW_VOCABULARY.VIEW_MYGROUPS %>" title="Groups you created...">your groups</a>
											| <a href="./<%=VIEW_VOCABULARY.ACTION_HOME%>?<%=VIEW_VOCABULARY.PARAMETER_MYHOME_VIEW %>=<%=VIEW_VOCABULARY.VIEW_SUBSCRIPTIONS %>" title="Groups you subscribed to...">your subscriptions</a>
											| <a href="./<%=VIEW_VOCABULARY.ACTION_HOME%>?<%=VIEW_VOCABULARY.PARAMETER_MYHOME_VIEW %>=<%=VIEW_VOCABULARY.VIEW_DASHBOARD %>" title="View what happened with your stuff...">your dashboard</a>
											| <a href="./<%=VIEW_VOCABULARY.ACTION_HOME%>?<%=VIEW_VOCABULARY.PARAMETER_MYHOME_VIEW %>=<%=VIEW_VOCABULARY.VIEW_CREATE_NEW_GROUP %>" title="Create a new group...">create a new group</a>
											| <a href="<%= VIEW_VOCABULARY.ACTION_MODIFY_ACCOUNT %>" title="Modify your GroupMe! account...">account settings</a> 
										</div>
									<h4>Authorize <i><%=appDesc%></i>?</h4>
									<p><i><%=appDesc%></i> tries to access your GroupMe! data. Do you want to allow <i><%=appDesc%></i>
									to create/modify GroupMe! groups on your behalf? </p>
									
									<form name="authZForm" action="authorize.do" method="post">
										<input type="hidden" name="<%=OAuthProtocol.USER %>" value="<%= userManager.getUser().getId() %>"/>
										<input type="hidden" name="<%=OAuthProtocol.AUTHORIZATION_GRANTED %>" value="true"/>
        								<input type="hidden" name="oauth_token" value="<%= token %>"/>
        								<input type="hidden" name="oauth_callback" value="<%= callback %>"/>
        								<input type="submit" name="Authorize" value="Yes, authorize!"/>
    								</form>
							   		</c:when>
							   		
									<c:otherwise>

									</c:otherwise>
								</c:choose>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		
	</div>
	
	<div id="footer">
		<%@ include file="../jsp-includes/footer.jsp" %>
	</div>
</body>
</html>